package com.ls.pattern.observer.mouse.core;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.lang.reflect.Method;

/**
 * 事件
 *
 * @author 挥之以墨
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Event {

    /**
     * 事件源
     */
    private Object source;
    /**
     * 事件监听器（观察者）
     */
    private EventListener listener;
    /**
     * 监听器回应（触发事件）
     */
    private Method callback;
    /**
     * 事件触发器，事件名称
     */
    private String trigger;
    /**
     * 事件的触发时间
     */
    private Long time;

    public Event(EventListener listener, Method callback) {
        this.listener = listener;
        this.callback = callback;
    }

    public Object getSource() {
        return source;
    }

    public void setSource(Object source) {
        this.source = source;
    }

    public EventListener getListener() {
        return listener;
    }

    public void setListener(EventListener listener) {
        this.listener = listener;
    }

    public Method getCallback() {
        return callback;
    }

    public void setCallback(Method callback) {
        this.callback = callback;
    }

    public String getTrigger() {
        return trigger;
    }

    public Event setTrigger(String trigger) {
        this.trigger = trigger;
        return this;
    }

    public Long getTime() {
        return time;
    }

    public void setTime(Long time) {
        this.time = time;
    }
}
